Myblog::System.controllers :withdraws do

  # get :index, :map => '/foo/bar' do
  #   session[:foo] = 'bar'
  #   render 'index'
  # end

  # get :sample, :map => '/sample/url', :provides => [:any, :js] do
  #   case content_type
  #     when :js then ...
  #     else ...
  # end

  # get :foo, :with => :id do
  #   "Maps to url '/foo/#{params[:id]}'"
  # end

  # get '/example' do
  #   'Hello world!'
  # end
  before :index do
    if current_admin
      check_super_role
    else
      @message = '请先登录'
      redirect url(:login, :index), :error => @message.html_safe+'<i class="close icon"></i>'.html_safe
    end
  end

  get :index do
    @manage_title = "提现管理"
    @bills = Bill.where(cash_type: "提现").order_by(created_at: "desc")
    render 'withdraws/index'
  end

  get :change_status, :with => :id do
    @bill = Bill.find(params[:id])
    @bill.status = params[:state]
    @bill.save

    if @bill.status == 1
      @bill.balance.amount = @bill.balance.amount - @bill.amount
      @bill.balance.save

    end



  end

end
